# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-pry-byebug
pkgver=3.10.1
pkgrel=1
pkgdesc="Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish', 'continue' and 'break' commands to control execution."
arch=(any)
url='https://github.com/deivid-rodriguez/pry-byebug'
license=(MIT)
depends=(ruby-byebug ruby-pry)
checkdepends=(ruby-rake ruby-mdl ruby-minitest)
options=(!emptydirs)
source=(https://github.com/deivid-rodriguez/pry-byebug/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('ae27542b6ee43425462d4f48aa04ae54e81ea462af0dbdc1d27403720d61dee4')

prepare() {
  cd pry-byebug-$pkgver
  sed -e 's|~>|>=|' -e '/chandler/d;/[rR]ubo[cC]op/d;/minitest-bisect/d' -i Gemfile Rakefile
}

build() {
  local _gemdir="$(gem env gemdir)"
  cd pry-byebug-$pkgver
  gem build pry-byebug.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    pry-byebug-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd pry-byebug-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rake test
}

package() {
  cd pry-byebug-$pkgver
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
